﻿@model IEnumerable<CourseOtherInfo>
@{
    var menuList = Model.Where(o => o.IsMenu.Value).ToList();

    CourseOtherInfo otherInfo = null;
    if (!string.IsNullOrEmpty(Convert.ToString(ViewData["OtherInfo"])))
    {
        otherInfo = ViewData["OtherInfo"] as CourseOtherInfo;
    }

    string otherInfoId = string.Empty;
    if (!string.IsNullOrEmpty(Convert.ToString(ViewData["OtherInfoId"])))
    {
        otherInfoId = ViewData["OtherInfoId"].ToString();
    }

    string pId = string.Empty;
    if (!string.IsNullOrEmpty(Convert.ToString(ViewData["PId"])))
    {
        pId = ViewData["PId"].ToString();
    }
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>课程内容介绍页面——@ViewData["TypeName"]</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
    <style type="text/css">
        .comment {
            background: #fff;
            padding: 10px;
        }

        h3 {
            border-bottom: 1px solid #ccc;
        }
        .list {
            padding: 0 25px 20px 25px;
        }
        .list .tip {
            text-align: center;
            color: gray;
            padding: 10px 0;
        }

        .list a {
            margin-right: 10px;
        }

        textarea {
            resize: none;
        }

        #btn[disabled] {
            background: gray;
            border-color: gray;
        }
        h4 {
            font-size: 18px;
            padding: 30px 25px 15px;
        }
        .form-horizontal {
            padding: 0 25px;
        }
    </style>
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">
                @ViewData["CourseName"]
                <br>
                <small>广州中医药大学康复治疗微课程网络学习平台</small>
            </h1>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicNav.cshtml", this.ViewData)
    <div class="container wrap mb15 mainwrap">
        <div class="row part">
            <div class="col-xs-3 colNav" id="JcolNav">
                @for (int i = 0, count = menuList.Count; i < count; i++)
                {
                    var selected1Css = "";
                    if (!string.IsNullOrEmpty(pId))
                    {
                        if (menuList[i].Id == pId)
                        {
                            selected1Css = "current";
                        }
                    }
                    else
                    {
                        if (i == 0)
                        {
                            selected1Css = "current";
                        }
                    }

                    <div class="navList @selected1Css">
                        <div class="navList-th">
                            <span class="flmark">@menuList[i].Title</span>
                        </div>
                        <ul class="navList-ul">
                            @{
                                var contentList = Model.Where(o => o.PId == menuList[i].Id).ToList();
                                for (int j = 0, cCount = contentList.Count; j < cCount; j++)
                                {
                                    var selected2Css = "";
                                    if (!string.IsNullOrEmpty(selected1Css) && otherInfoId == contentList[j].Id)
                                    {
                                        selected2Css = "current";
                                    }
                                    else
                                    {
                                        if (j == 0 && i == 0 && string.IsNullOrEmpty(otherInfoId))
                                        {
                                            selected2Css = "current";
                                        }
                                    }

                                    <li class="@(j == 0 ? "first" : "")  @(j == cCount - 1 ? "last" : "")">
                                        <a class="@selected2Css" href="javascript:void(0)">@contentList[j].Title</a>
                                        <input type="hidden" name="OtherInfoId" value="@contentList[j].Id" />
                                    </li>
                                }
                            }
                        </ul>
                    </div>
                }
            </div>
            <div class="col-xs-9 pl5 mainwrap-part">
                @if (otherInfo != null)
                {
                    <div class="artTop">
                        <h1 class="artTit">@otherInfo.Title</h1>
                        <p class="artSub">
                            <span>@otherInfo.CreateTime.ToTimeString("yyyy-MM-dd HH:mm:ss")</span>
                            <span>作者：@otherInfo.Creator</span>
                        </p>
                    </div>
                    <div class="artTxt">
                        @if (otherInfo.IsSimpleType.Value)
                        {
                            <object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="856" height="730">
                                <param name="wmode" value="transparent">
                                <param name="allowScriptAccess" value="always" />
                                <param name="movie" value="@WebSiteDomain.ResFileDomain/@otherInfo.CourseContent">
                                <param name="quality" value="High">
                                <embed src="@WebSiteDomain.ResFileDomain@otherInfo.CourseContent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1" width="856" height="730" quality="High">
                            </object>
                        }
                        else
                        {
                            @Html.Raw(otherInfo.CourseContent)
                        }
                    </div>
                }

                <h4>课程评论</h4>
                <div class="form-horizontal">
                    <div class="form-group">
                        <textarea class="form-control" id="content" rows="5" maxlength="1000" value="" placeholder="限于1000字以内"></textarea>
                    </div>
                    <div class="form-group" style="text-align:right">
                        <button class="btn btn-success" id="btn">回复</button>
                    </div>
                </div>

                <div class="list" id="list">
                    <div class="lBox part">
                        <div class="lBox-th">
                            <h3>讨论区</h3>
                        </div>
                        <div class="lBox-tb">
                            <table class="table table-bordered tlqny">
                                <tbody id="JListContent"></tbody>
                            </table>
                            <div class="row clearfix well d-page">
                                <div id="PagInfo" class="pull-left sum"></div>
                                <div class="clearfix pull-right">
                                    <ul id="PageTool" class="pagination"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                @*<div class="page_wrap">
                    <div class="clearfix well d-page">
                        <div id="PagInfo" class="pull-left sum">
                        </div>
                        <div class="clearfix pull-right">
                            <ul id="PageTool" class="pagination"></ul>
                        </div>
                    </div>
                </div>*@
                

            </div>


        </div>
    </div>

    <div class="modal fade bs-example-modal-lg" tabindex="-1" id="Jreply" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content reply-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">
                        <span aria-hidden="true">&times;</span>
                        <span class="sr-only">Close</span>
                    </button>
                    <h4 class="modal-title">回复</h4>
                </div>
                <div class="modal-body">
                    <p class="pTit">
                        RE: <em id="JemTit"></em>
                    </p>
                    <p class="pTxt" id="JpTxt"></p>
                    <p class="mb10">
                        <textarea class="form-control" id="JreplyContent" rows="5" maxlength="1000"></textarea>
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" id="JreplyBtn" class="btn btn-info" data-dismiss="modal">提 交</button>
                </div>
            </div>
        </div>
    </div>





    @Html.Partial("~/Views/Share/PublicFooter.cshtml")
    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
    <script src="~/Content/kindeditor/plugins/insertVideo/ckplayer6.7/ckplayer.js"></script>
    <script src="~/Content/kindeditor/plugins/insertVideo/ckplayer6.7/callCkplayer6.7.js"></script>
    <script>
        var navListUl = $(".navList-ul"),
            navList = $(".navList");
        var $list = $("#list");
        var _courseId = $.getUrlParam("CourseId") || $.getUrlParam("courseId");
        var OtherInfoId = $.getUrlParam("OtherInfoId");
        var TypeCode = $.getUrlParam("TypeCode");
        // var _id = $.getUrlParam("TypeCode");
        var navListUl = $(".navList-ul"),
            navList = $(".navList");
        var JemTit = $("#JemTit"),
            Jptxt = $("#JpTxt"),
            JreplyContent = $("#JreplyContent");
        var pageNo = 1;

        $("#JcolNav").click(function (e) {
            var _target = $(e.target);
            if (_target.hasClass("navList-th") || _target.parent().hasClass("navList-th")) {
                var _navList = _target.parent().hasClass("navList") ? _target.parent() : _target.parent().parent();
                if (_navList.hasClass("current")) {
                    navListUl.slideUp();
                    _navList.removeClass("current");
                } else {
                    navListUl.slideUp();
                    $(".navList-ul", _navList).slideDown();
                    navList.removeClass("current");
                    _navList.addClass("current");
                }
            }
        })

        $(".navList-ul li").click(function () {
            var _selected1 = $('div.navList').index($("div.current")[0]);
            var _otherInfoId = $(this).find("input[name='OtherInfoId']").val();
            window.location.href = "@Url.Action("CourseOtherInfoBrowse", "CourseOtherInfo")?TypeCode=@ViewData["TypeCode"]&CourseId=@ViewData["CourseId"]&OtherInfoId=" + _otherInfoId + "&Selected1=" + _selected1;

        });
        /*
        $(function () {
            var videos = $("embed");
            var videoId = 0;
            videos.each(function (index, ele) {
                var self = $(this);
                var src = self.attr("src");
                self.attr("flashvars", src);
                self.attr("src", "http://www.ckplayer.com/ckplayer/6.5/ckplayer.swf");
                var id = "vedio" + videoId;
                videoId++;
                self.attr("Id", id);
                var flashvars = {
                    f: 'http://movie.ks.js.cn/flv/other/1_0.mp4',
                    c: 0,
                    loaded: 'loadedHandler'
                };
                var video = ['http://movie.ks.js.cn/flv/other/1_0.mp4->video/mp4'];
                CKobject.embed('ckplayer/ckplayer.swf', id, id, '600', '400', false, flashvars, video);

            });
        });
        */

        $(document).ready(function () {
            initHtml();
            getCourseInfo();
            $(window).bind("click", function (e) {
                var _self = $(e.target);
                if (_self.hasClass("btn-reply") || _self.parent().hasClass("btn-reply")) {
                    var self = _self.hasClass("btn-reply") ? _self : _self.parent();
                    var _tr = self.parents("tr");
                    if (_tr.length > 0) {
                        var _name = $(".pName", _tr).text();
                        JemTit.text(_name);
                        var dTxtHtml = $.trim($(".dReplyTxt", _tr).html())

                        Jptxt.attr("data-html", dTxtHtml);
                        replyAuthor = false;
                    } else {
                        var _name = $(".pName", Jzt).text();
                        JemTit.text(_name);
                        var dTxtHtml = $.trim($(".dReplyTxt", _tr).html())


                        Jptxt.attr("data-html", dTxtHtml);
                        replyAuthor = true;
                    }
                    JreplyContent.val("");
                    $('#Jreply').modal("show")
                }
            })
            $("#JcolNav").delegate("div","click",function (e) {
                e.stopPropagation();
                var _target = $(e.target);
                if (_target.hasClass("navList-th") || _target.parent().hasClass("navList-th")) {
                    var _navList = _target.parent().hasClass("navList") ? _target.parent() : _target.parent().parent();
                    if (_navList.hasClass("current")) {
                        navListUl.slideUp();
                        _navList.removeClass("current");
                    } else {
                        navListUl.slideUp();
                        $(".navList-ul", _navList).slideDown();
                        navList.removeClass("current");
                        _navList.addClass("current");
                    }
                }
            })
            $("#JreplyBtn").bind("click", function () {
                var ReplyContent = "";
                var val = JreplyContent.val();
                if (!replyAuthor) {
                    ReplyContent = "<div class='lgray f12 replyDiv'>" + Jptxt.attr("data-html") + "<br>" + $(".pTit", $('#Jreply')).text().trim() + "</div>";
                }

                if (!val) {
                    alert("评论内容不能为空");
                    return;
                } else if (val.length > 1000) {
                    alert("评论内容限于1000字以内");
                    return;
                }
                ReplyContent += JreplyContent.val();
                var pars = {
                    "CourseId": _courseId,
                    "CourseOtherInfoId": OtherInfoId,
                    "Content": ReplyContent,
                    "TypeCode": TypeCode
                };
                saveComment(pars, 2);
            })


            $("#btn").bind("click", comment);
            getPage();
            getList(pageNo);
        });

        //评论
        function comment(e) {
            var content = $("#content").val().trim();
            if (!content) {
                alert("评论内容不能为空");
                return;
            } else if (content.length > 1000) {
                alert("评论内容限于1000字以内");
                return;
            }
            var pars = {
                "CourseId": _courseId,
                "CourseOtherInfoId": OtherInfoId,
                "Content": content,
                "TypeCode": TypeCode
            };

            saveComment(pars, 1);
        }

        function saveComment(pars, type) {
            if (type === 1) {
                $("#btn").attr("disabled", "disabled");
            }
            $.easyPost1("/CourseOtherInfo/AddDiscuss", pars, undefined, function (res) {
                if (type === 1) {
                    $("#content").val("");
                    $("#btn").removeAttr("disabled");
                    getPage();
                    getList(pageNo);
                } else {
                    showTips.open("回复成功！");
                    $('#Jreply').modal("hide");
                    JreplyContent.val("");
                    getPage();
                    getList(pageNo)
                }
            });
        }

        function zan(id, dom) {
            $.easyPost1("/CourseOtherInfo/AddZan", id, function (res) {
                var txt = Number($(this).text() || 0);
                $(this).text(txt + 1);
            });
        }

        function feedback(id) {
            $.easyPost1("/CourseOtherInfo/AddZan", { id: id }, function (res) {
                var txt = Number($(this).text() || 0);
                $(this).text(txt + 1);
            });
        }

        function getList(pageNo) {
            //JListContent
            $.easyGet("/CourseOtherInfo/GetDiscussList", { "pageNO": pageNo, "pageSize": "10", "id": OtherInfoId, "courseId": _courseId,"TypeCode": TypeCode}, undefined, function (data) {
                var _html = '';
                if (data.rows && data.rows.length > 0) {
                    $(".d-page").show();

                    var _row = data.rows,
                        _rowL = _row.length;
                    options = {
                        totalPages: data.totalPage,
                        total: data.total,
                        currentPage: pageNo,
                        onPageClicked: function (event, originalEvent, type, page) {
                            getList(page);
                        }
                    }
                    initialPaginator(options, "PageTool", "PagInfo");

                    for (var i = 0; i < _rowL; i++) {
                        var item = _row[i];
                        _html += '<tr>' +
                            '<td class="td1" width="18%">' +
                            '<div class="userInfo">' +
                            '<p class="pName">' + item.Creator + '</p>' +
                            '<p class="pPic">' +
                            '<img src="/' + item.Portrait + '" width="120" height="120" alt="">' +
                            '</p>' +
                            '<p class="pInt">' +
                            '已发帖：' + item.ZanCount +
                            '</p>' +
                            '</div>' +
                            '</td>' +
                            '<td class="td2" width="82%">' +
                            '<div class="dReplyTxt">' + item.Content + '</div>' +
                            '<div class="dz text-right">' +
                            '<button type="button" class="btn btn-info btn-sm btn-reply">' +
                            '<span class="glyphicon glyphicon-comment"></span> 回复' +
                            '</button>' +
                            '</div>' +
                            '</td>' +
                            '</tr>';
                    }
                }
                else {
                    _html = "<tr><td colspan='2' style='text-align:center'>暂无评论!</td></tr>";
                    $(".d-page").hide();
                }
                $("#JListContent").html(_html);
            });
        }

        $(document).ready(function () {
            var str = $("#PublicNav li .current").text();
            var title = $(".artTop .artTit").text();
            monitor({
                "CourseId": _courseId,
                "PageName": str + "-" + title,
                "PageCode": "CourseOtherInfoBrowse",
                "ContentInfo": str + "-" + title,
            });
        });

    </script>
</body>
</html>
